//
//  UserInfoVC.swift
//  WeFamily
//
//  Created by 崔世强 on 2020/7/7.
//  Copyright © 2020 Meak Tsui. All rights reserved.
//

import UIKit
import Kingfisher
//import MTSDK

class UserInfoVC: UITableViewController {

    @IBOutlet weak var avatarView: UIImageView!
    @IBOutlet weak var nameLabel: UILabel!
    @IBOutlet weak var uidLabel: UILabel!
    @IBOutlet weak var genderLabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        let Defaults = UserDefaults(suiteName: USER_DEFAULTS_NAME)!
        nameLabel.text = Defaults[.username]
        uidLabel.text = String(Defaults[.userId] ?? 0)
        if let gender = Defaults[.userGender] {
            genderLabel.text = gender == "1" ? "男" : "女"
        } else {
            genderLabel.text = ""
        }
        let avatar = Defaults[.userAvatar] ?? ""
        avatarView.kf.setImage(with: KF.ImageResource(downloadURL: Common.imgOrigUrl(avatar) ?? URL(string: "localhost")!), placeholder: #imageLiteral(resourceName:"defaultAvatar"),options: [.processor(CryptorProcessor())])
    }

    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    }
    
}
